/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.general.bc;

import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.cip.esymons.general.be.Rubro;

/**
 *
 * @author oscar
 */
@Stateless
public class RubroFacade implements RubroFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(Rubro rubro) {
        em.persist(rubro);
    }

    public void edit(Rubro rubro) {
        em.merge(rubro);
    }

    public void remove(Rubro rubro) {
        Rubro aux = em.merge(rubro);
        em.remove(aux);
    }

    public Rubro find(Object id) {
        return em.find(Rubro.class, id);
    }

    public List<Rubro> findAll() {
        try {
            return em.createQuery("select object(o) from Rubro as o order by o.rubDescripcion asc").getResultList();
        } catch (Exception e) {
            return new ArrayList();
        }        
    }



}
